package com.atguigu.gmall.realtime.util;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

/**
 * @Author lizhenchao@atguigu.cn
 * @Date 2021/8/28 10:58
 */
public class RedisUtil {
    private static JedisPool pool;
    
    static {
        JedisPoolConfig conf = new JedisPoolConfig();
        conf.setMaxTotal(300);
        conf.setMaxIdle(5);
        conf.setMaxWaitMillis(10000);
        conf.setTestOnCreate(true);
        conf.setTestOnBorrow(true);
        conf.setTestOnReturn(true);
        conf.setMinIdle(2);
        pool = new JedisPool(conf, "hadoop162", 6379);
    }
    
    public static Jedis getRedisClient() {
        
        return pool.getResource();
        
    }
}
